package com.yugao.fintech.libra.auth.api.service;

import com.yugao.fintech.meheco.core.constant.SecurityConstants;
import com.yugao.fintech.meheco.core.constant.ServiceIdConstants;
import com.yugao.fintech.meheco.core.domain.ResultVO;
import com.yugao.fintech.libra.auth.api.factory.RemoteUserFallbackFactory;
import com.yugao.fintech.libra.auth.model.LoginUser;
import com.yugao.fintech.libra.auth.model.SysUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户服务
 */
@FeignClient(contextId = "remoteUserService", value = ServiceIdConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface UserFeignApi {
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source   请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    public ResultVO<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过用户id查询用户信息
     *
     * @param id     用户id
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/user/inner/info/{id}")
    public ResultVO<SysUser> getUserInfoById(@PathVariable("id") Long id, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source  请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    public ResultVO<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/inner/all/list")
    public ResultVO<List<SysUser>> getUserAll(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
